import request from '@/config/axios'

export interface ProductionTaskOrderVO {
  creatorName: string
  workTaskNumber: string
  productNumber: string
  productName: string
  productStandard: string
  productDrawingNumber: string
  orderQuantity: number
  serialNumber: string
  partNumber: string
  partName: string
  partDrawingNumber: string
  partSpecification: string
  material: string
  specification: string
  plannedQuantity: number
  processName: string
  typeOfWork: string
  cuttingType: string
  machiningProcess: string
  productionTeam: string
  deviceName: string
  deviceCode: string
  operator: string
  planStartDate: Date
  planEndDate: Date
  warehousePosition: string
  productiveTaskStatus: number
  internalWork: number
  outsourcing: number
  outsidePurchase: number
  taskNumber: number
  netSizeLength: number
  netSizeWidth: number
  cuttingSizeLength: number
  cuttingSizeWidth: number
  dictIsMachine: number
  jobNumber: string
  basicDosage: number
}

// 查询生产管理-工单管理-生产任务单列表
export const getProductionTaskOrderPage = async (params) => {
  return await request.get({ url: `/produce/production-task-order/page`, params })
}

// 查询生产管理-工单管理-生产任务单列表(id)
export const getProductionTaskOrderList = async (ids) => {
  return await request.get({ url: `/produce/production-task-order/list?ids=`+ ids })
}

// 查询生产管理-工单管理-生产任务单详情
export const getProductionTaskOrder = async (id: number) => {
  return await request.get({ url: `/produce/production-task-order/get?id=` + id })
}

// 批量提交
export const putProductionTaskOrderList = async (data) => {
  return await request.put({ url: `/produce/production-task-order/submit`, data})
}

// 新增生产管理-工单管理-生产任务单
export const createProductionTaskOrder = async (data: ProductionTaskOrderVO) => {
  return await request.post({ url: `/produce/production-task-order/create`, data })
}

// 修改生产管理-工单管理-生产任务单
export const updateProductionTaskOrder = async (data: ProductionTaskOrderVO) => {
  return await request.put({ url: `/produce/production-task-order/update`, data })
}

// 删除生产管理-工单管理-生产任务单
export const deleteProductionTaskOrder = async (id: number) => {
  return await request.delete({ url: `/produce/production-task-order/delete?id=` + id })
}

// 导出生产管理-工单管理-生产任务单 Excel
export const exportProductionTaskOrder = async (data) => {
  return await request.download({ url: `/produce/production-task-order/export-excel`, data })
}

// 获取生产班组
export const getOrgTeamArchives = async (params) => {
  return await request.get({ url: `/config/org-team-archives/list-all-simple`, params })
}

//获取设备名称、编码
export const getDeviceMessageList = async (params) => {
  return await request.post({ url: `/config/device-archives/list-all-simple`, params})
}

// // 获取作业者
// export const getOperatorList = async (id) => {
//   return await request.get({ url: `/config/org-staff-archives/list?ids=`+ id})
// }

// 查询配置中心-人员档案所有数据（名称查询）
export const getStaffList = async (keyword) => {
  return await request.get({ url: `/config/org-staff-archives/list-all-simple?keyword=${keyword}` })
}

// 审核
export const putExamine = async (data) => {
  return await request.put({ url: '/produce/production-task-order/examine', data})
}

// 保存
export const putSave = async (data) => {
  return await request.put({ url: '/produce/production-task-order/update', data})
}

// 位置
export const getWarehousePosition = async (params) => {
  return await request.get({ url: `/config/warehouse-archives/list-all-simple`, params})
}
